<template>
  <div class="wrapper" ref="wrapper">
    <div class="content">
      <slot></slot>
    </div>
  </div>
</template>

<script>
import BScroll from "better-scroll"
export default {
  name: "Scroll",
  methods: {
    refresh() {
      this.scroll.refresh()
      console.log("---");
    },
    getPositionY() {
      return this.scroll ? this.scroll.y : 0
    }
  },
  data() {
    return {
      scroll: null,
      scrollPosition: 0
    }
  },
  props: {
    srcollType: {
      type: Number,
      default: 0
    },
    pullUpLoad: {
      type: Boolean,
      default: true
    }
  },
  mounted() {
    this.scroll = new BScroll(this.$refs.wrapper, {
      probeType: this.srcollType,
      pullUpLoad: this.pullUpLoad,
      click: true,
      bounce: true,
      disableTouch: false,
      observeDOM: true,
      observeImage: true
    })
    this.scroll.on("scroll", (position) => {
      this.scroll && this.$emit("scroll", position.y)
    })
    this.scroll.on("pullingUp", () => {
      this.scroll && this.$emit("pullingUp")
    })
  },
}
</script>

<style scoped>
</style>